package com.gc.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gc.Common.result.Result;
import com.gc.Common.result.ResultUtils;
import com.gc.entity.OrderDetail;
import com.gc.entity.Type;
import com.gc.service.IOrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Yuyingying
 * @since 2024-09-05
 */
@RestController
@RequestMapping("/order-detail")
public class OrderDetailController {
    @Autowired
    IOrderDetailService service;
    @RequestMapping("/getList")
    public Result<OrderDetail> getList(Integer orderId) {
        //封装查询条件，排序方式
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("order_id", orderId);
        //带条件的查询
        List list = service.list(queryWrapper);
        return ResultUtils.returnSuccessLayui(list, list.size());
    }
    @RequestMapping("/add")
    public Object add(OrderDetail orderDetail){
        if(service.save(orderDetail)){
            return ResultUtils.returnSuccess();
        }else{
            return ResultUtils.returnFail("添加失败");
        }
    }


}
